/***********************************************************************
 * Module:  IstorijaPdv.java
 * Author:  Igor Spremo, Milan Stojkov
 * Purpose: Defines the Class IstorijaPdv
 ***********************************************************************/

package model.entity;

import java.io.Serializable;
import java.sql.Date;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;

/**
 * 
 * @author Igor Spremo, Milan Stojkov
 *
 */

@SuppressWarnings("serial")
public class IstorijaPdv implements Serializable {
	
	protected Integer id;
	protected Date datumPocetkaVazenja;
	protected Date datumKrajaVazenja;
	protected int verzija;

	protected Collection<PDV> pdv;

	public Collection<PDV> getPdv() {
		if (pdv == null)
			pdv = new HashSet<PDV>();
		
		return pdv;
	}

	public Iterator<PDV> getIteratorPdv() {
		if (pdv == null)
			pdv = new HashSet<PDV>();
		
		return pdv.iterator();
	}

	public void setPdv(Collection<PDV> newPdv) {
		removeAllPdv();
		for (Iterator<PDV> iter = newPdv.iterator(); iter.hasNext();)
			addPdv((PDV) iter.next());
	}

	public void addPdv(PDV newPdv) {
		if (newPdv == null)
			return;
		if (this.pdv == null)
			this.pdv = new HashSet<PDV>();
		if (!this.pdv.contains(newPdv))
			this.pdv.add(newPdv);
	}

	public void removePDV(PDV oldPdv) {
		if (oldPdv == null)
			return;
		if (this.pdv != null)
			if (this.pdv.contains(oldPdv))
				this.pdv.remove(oldPdv);
	}

	public void removeAllPdv() {
		if (pdv != null)
			pdv.clear();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getDatumPocetkaVazenja() {
		return datumPocetkaVazenja;
	}

	public void setDatumPocetkaVazenja(Date datumPocetkaVazenja) {
		this.datumPocetkaVazenja = datumPocetkaVazenja;
	}

	public Date getDatumKrajaVazenja() {
		return datumKrajaVazenja;
	}

	public void setDatumKrajaVazenja(Date datumKrajaVazenja) {
		this.datumKrajaVazenja = datumKrajaVazenja;
	}

	public int getVerzija() {
		return verzija;
	}

	public void setVerzija(int verzija) {
		this.verzija = verzija;
	}

}